// pages/more/index.js
const createRecycleContext = require('miniprogram-recycle-view')
const login=require('../../wechat-lib/login');
const common=require('../../wechat-lib/common');
const request=require('../../wechat-lib/request');
let cxt=null;
Page({
  mixins: [require('../../wechat-lib/themeChanged')],
  /**
   * 页面的初始数据
   */
  data: {
    page:1
  },
  onReady:function(){
    cxt=createRecycleContext({
      id:"main",
      dataKey:"recycleList",
      page:this,
      itemSize:this.itemSize
    });
    
    login.getJwtPayload().then(_jwt=>{
      request.post("album","list",{"page":this.data.page}).then(
        success=>{
          cxt.append(success.data)
          //console.log(success)
          this.setData({
            page:this.data.page+1
          })
        }
      )
      }
    )
  }, 
  itemSize:function(item,idx){
    return {
      width: cxt.transformRpx(750),
      height: cxt.transformRpx(421)
    }
  },


  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
    console.log("xx")
    setTimeout(() => {
      login.getJwtPayload().then(_jwt=>{
        request.post("album","list",{"page":this.data.page}).then(
          success=>{
            cxt.append(success.data)
            this.setData({
              page:this.data.page+1
            })
            //console.log(success)
          }
          
        )
        }
      )
    }, 500);
    
  },
  bindscrolltolower:function(res){ 
    
    console.log("bindscrolltolower",res)
  }
})